class Solution:
    def longestPalindrome(self, s: str) -> str:
        l = len(s)
        if l == 1:
            return s
        s_list = list(str(s))
        maxlen = 1 
        start = 0
        for i in range(l - 1):
            j = l - 1
            while i != j:
                if s_list[i] == s_list[j] and s[i:j:1] == s[j:i:-1]:
                    if maxlen < j - i + 1:
                        start = i
                        maxlen = j - i + 1
                    break
                j -= 1
        return s[start:start + maxlen] 